﻿using System;
using System.Collections.Generic;

namespace Zyg.SSO.Core.Providers.DALProviders
{
    public abstract partial class DALProvider//  : System.Configuration.Provider.ProviderBase
    {
        #region Account

        /// <summary>
        /// Retrieves a Account from the provider based on the specified id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public abstract Business.Account SelectAccount(Guid id);

        public abstract Business.Account SelectAccount(string email);

        public abstract void InsertAccount(Business.Account account);

        public abstract void DeleteAccount(Business.Account account);

        public abstract void UpdateAccount(Business.Account account);


        public abstract IList<Business.Account> FillAccounts();

        public abstract IList<Business.Account> FillAccounts(Business.Role role);

        public abstract IList<Business.Account> FillAccounts(string email, string name, Business.AccountState state, bool? isAdmin, Guid? roleId, DateTime? startTime, DateTime? endTime, int? startIndex, int? endIndex);

        public abstract Boolean ExistsAccount(string email);


        #endregion

        #region Log
        public abstract Business.Log SelectLog(int id);
        public abstract void InsertLog(Business.Log log);
        public abstract void DeleteLog(Business.Log log);
        public abstract void UpdateLog(Business.Log log);
        public abstract IList<Business.Log> FillLogs();
        #endregion

        #region Role

        public abstract Business.Role SelectRole(Guid id);

        public abstract void InsertRole(Business.Role role);

        public abstract void DeleteRole(Business.Role role);

        public abstract void UpdateRole(Business.Role role);

        public abstract Boolean ExistsRole(string name);

        public abstract IList<Business.Role> FillRoles();

        #endregion

        #region App

        public abstract Business.App SelectApp(Guid id);

        public abstract void InsertApp(Business.App app);

        public abstract void DeleteApp(Business.App app);

        public abstract void UpdateApp(Business.App app);

        public abstract IList<Business.App> FillApps();

        #endregion

        #region AccountApp

        public abstract Business.AccountApp SelectAccountApp(Guid id);

        public abstract Business.AccountApp SelectAccountApp(Guid accountId, Guid appId);

        public abstract void InsertAccountApp(Business.AccountApp accountApp);

        public abstract void DeleteAccountApp(Business.AccountApp accountApp);

        public abstract void DeleteAccountApps(Business.Account account);

        public abstract void DeleteAccountApps(Business.App app);

        public abstract void UpdateAccountApp(Business.AccountApp accountApp);

        public abstract void DeleteUpdateAccountApps(Business.Account account, IList<Business.AccountApp> newRelations);

        public abstract void DeleteUpdateAccountApps(Business.App app, IList<Business.AccountApp> newRelations);

        public abstract void DeleteUpdateAccountApps(Business.Account account, Business.App app, IList<Business.AccountApp> newRelations);

        public abstract IList<Zyg.SSO.Core.Business.AccountApp> FillAccountApps(Business.Account account, Business.App app);

        #endregion

        #region AccountAppUser

        public abstract Business.AccountAppUser SelectAccountAppUser(Guid id);

        public abstract void InsertAccountAppUser(Business.AccountAppUser accoutAppUser);

        public abstract void DeleteAccountAppUser(Business.AccountAppUser accoutAppUser);

        public abstract void DeleteAccountAppUsers(Business.AccountApp accountApp);

        public abstract void UpdateAccountAppUser(Business.AccountAppUser accoutAppUser);

        public abstract IList<Business.AccountAppUser> FillAccountAppUsers(Business.AccountApp accountApp);

        #endregion

        #region SysSetting

        public abstract Business.SysSetting SelectCurrentSetting();

        public abstract void InsertSysSetting(Business.SysSetting setting);

        #endregion

        #region Role Permission

        public abstract void UpdateRolePermission(Business.Role role, List<Business.RolePermission> per);

        public abstract void InsertRolePermission(Business.RolePermission roleper);

        public abstract List<Business.Permission> SelectPermissionByRoleID(Guid roleid);

        #endregion
    }

    public class SSOProviderCollection// : System.Configuration.Provider.ProviderCollection
    {
        /*

        /// <summary>
        /// Gets a provider by its name
        /// </summary>
        public new SSOProvider this[string name]
        {
            get { return base[name] as SSOProvider; }
        }

        public override void Add(System.Configuration.Provider.ProviderBase provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            if (!(provider is SSOProvider))
            {
                throw new ArgumentException("Invalid provider type", "provider");
            }

            base.Add(provider);
        }*/
    }
}
